
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>slot_attribute</title>
    <script src="https://cdn.bootcss.com/vue/2.6.10/vue.js"></script>
</head>
<body>
    <div id="app">
        <span>
            {{ user.lastName }}
        </span>
        <current-user>
            <template v-slot:default="slotProps">
                {{ slotProps.user.firstName }}
            </template>
        </current-user>
    </div>
    <script>
        Vue.component('current-user', {
            template: `
                <span>
                    <slot v-bind:user="user">
                        {{ user.lastName }}
                    </slot>
                </span>
            `
        });
        var app = new Vue({
            el: '#app',
            data: {
                user: {
                    lastName: '张',
                    firstName: '伯谦'
                },
                slotProps: {
                    user: {
                        lastName: '张',
                        firstName: '伯谦'
                    }
                }
            }
        });
    </script>
</body>
</html>
